feat: implement shared backend interface and selection model#487
Merged
niteshpurohit merged 13 commits intomainfrom May 3, 2026
Merged
Conversation
- Added a new Backend module to encapsulate backend selection logic. - Introduced classes for Capabilities, Descriptor, and InMemory backend. - Implemented a Selection class for normalizing backend identifiers. - Defined RBS types for backend identifiers and classifications. - Updated documentation to reflect new backend selection contracts. - Added tests for backend capabilities, descriptor, and selection logic. closes: #105
There was a problem hiding this comment.
Pull request overview
This PR introduces the first shared backend contract in core/karya, adding a backend namespace that describes backend identity, capability reporting, lifecycle hooks, and identifier normalization on top of the existing queue-store layer. It also adds mirrored RBS and focused specs so later adapter/framework work can target one common backend selection model instead of ad hoc conventions.
Changes:
- Add
Karya::Backendruntime types for backend selection, descriptors, capabilities, a base contract, and anInMemorybackend wrapper. - Add mirrored RBS for backend identifiers/classifications and the new backend classes/modules.
- Add backend-focused specs and update review/RBS instructions to tighten how accepted input surfaces should be modeled.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
core/karya/spec/karya/backend/selection_spec.rb |
Adds specs for backend identifier normalization, classification, and support checks. |
core/karya/spec/karya/backend/in_memory_spec.rb |
Adds specs for the new in-memory backend descriptor, queue-store construction, and lifecycle hooks. |
core/karya/spec/karya/backend/descriptor_spec.rb |
Adds specs for descriptor normalization and validation behavior. |
core/karya/spec/karya/backend/capabilities_spec.rb |
Adds specs for capability flag validation and parity exception handling. |
core/karya/spec/karya/backend/base_spec.rb |
Adds specs for the shared backend base contract and descriptor delegation. |
core/karya/sig/karya/backend/selection.rbs |
Declares RBS for backend selection normalization and classification helpers. |
core/karya/sig/karya/backend/in_memory.rbs |
Declares RBS for the concrete in-memory backend wrapper. |
core/karya/sig/karya/backend/descriptor.rbs |
Declares RBS for backend descriptors. |
core/karya/sig/karya/backend/capabilities.rbs |
Declares RBS for backend capability metadata. |
core/karya/sig/karya/backend/base.rbs |
Declares the shared backend interface in RBS. |
core/karya/sig/karya/backend.rbs |
Adds top-level backend namespace and backend-selection error classes to RBS. |
core/karya/sig/karya.rbs |
Adds backend identifier/classification type aliases used by the new backend API. |
core/karya/lib/karya/backend/selection.rb |
Implements backend identifier aliasing, normalization, and deployment classification helpers. |
core/karya/lib/karya/backend/in_memory.rb |
Adds the first concrete backend wrapper around QueueStore::InMemory. |
core/karya/lib/karya/backend/descriptor.rb |
Implements backend descriptor normalization and validation. |
core/karya/lib/karya/backend/capabilities.rb |
Implements immutable-ish backend capability metadata and validation. |
core/karya/lib/karya/backend/base.rb |
Introduces the shared backend contract and default lifecycle hooks. |
core/karya/lib/karya/backend.rb |
Adds the backend namespace, errors, and autoload wiring. |
core/karya/lib/karya.rb |
Loads the new backend namespace from the main library entrypoint. |
.github/instructions/review.instructions.md |
Updates review guidance for accepted input surfaces and shared-contract RBS exactness. |
.github/instructions/core-karya-rbs.instructions.md |
Updates Core Karya RBS instructions with backend-input and shared-contract typing rules. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 25 out of 25 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (1)
docs/pages/backends.md:33
- This section is now titled "Backend Identifiers", but the table still lists display names like
Postgres,Redis,MySQL, andSQLite. The newSelectioncontract only accepts the lowercase identifiers (postgres,redis,mysql,sqlite), so presenting the title-cased names here will mislead readers into using values that the code rejects.
## Backend Identifiers
| Backend | Position | Typical Fit |
| ---------- | ----------------------------- | ------------------------------------------------------ |
| Postgres | Default production backend | General-purpose production deployments |
| Redis | Supported production backend | Queue-centric, low-latency operational workloads |
| MySQL | Supported production backend | SQL environments standardized on MySQL |
| SQLite | Supported constrained backend | Embedded, single-node, or lightweight SQL deployments |
| `InMemory` | Local/dev/test backend | Examples, development, tests, and ephemeral evaluation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Karya::Backendcontract with identifier normalization, backend descriptors, lifecycle hooks, and the minimalInMemorybackend wrapper.Karya::Backend::Selectionas the shared backend identifier model forin_memory,sqlite,redis,postgres, andmysql.Backend::InMemory#build_queue_storeand hardened the supervisor signal path so runtime phase writes are best-effort only after the runtime claim exists.closes: #105